import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    meta: {
      title: '登录界面'
    },
    redirect: '/adminLogin'
  },

  //前台
  // {
  //   path: '/index',
  //   name: 'index',
  //   meta: {
  //     title: '主页'
  //   },
  //   component: () => import('../views/ui/index.vue'),
  //   redirect: '/index/home',
  //   children: [
  //     {
  //       path: 'home',
  //       name: 'home',
  //       meta: {
  //         title: '首页'
  //       },
  //       component: () => import('../views/ui/Home.vue')
  //     },
  //     {
  //       path: 'clubList',
  //       name: 'clubList',
  //       meta: {
  //         title: '社团列表'
  //       },
  //       component: () => import('../views/ui/club/ClubList.vue')
  //     },
  //     {
  //       path: 'activities',
  //       name: 'activities',
  //       meta: {
  //         title: '社团列表'
  //       },
  //       component: () => import('../views/ui/activity/Activities.vue')
  //     },
  //     {
  //       path: 'news',
  //       name: 'news',
  //       meta: {
  //         title: '新闻列表'
  //       },
  //       component: () => import('../views/ui/news/News.vue')
  //     },
  //   ]
  // },

  //学生管理员后台
  //登录
  {
    path: '/adminLogin',
    name: 'adminLogin',
    meta: {
      title: '管理员登录界面'
    },
    component: () => import('../views/manager/AdminLogin.vue')
  },
  //管理页
  {
    path: '/managerHome',
    name: 'ManagerHome',
    meta: {
      title: '主页'
    },
    component: () => import('../views/manager/ManagerHome.vue'),
    redirect: '/managerHome/manageWelcome',
    children: [
      {
        path: 'manageWelcome',//暂时与managerHomeT的welcome重复定义，有警告
        name: 'ManageWelcome',
        meta: {
          title: '学生端后台管理'
        },
        component: () => import('../views/manager/Welcome.vue')
      },
      // {
      //   path: 'clubHome/:id',
      //   name: 'ClubHome',
      //   meta: {
      //     title: '社团主页'
      //   },
      //   component: () => import('../views/manager/clubmanage/clubhome/ClubHome.vue')
      //   ,
      //   children: [
      //     {
      //       path: 'clubNews',
      //       name: 'clubNews',
      //       meta: {
      //         title: '社团资讯'
      //       },
      //       component: () => import('../views/manager/clubmanage/clubhome/ClubNews.vue')
      //     },
      //     {
      //       path: 'clubActivity',
      //       name: 'clubActivity',
      //       meta: {
      //         title: '社团活动'
      //       },
      //       component: () => import('../views/manager/clubmanage/clubhome/clubActivity.vue')
      //     }
      //   ],
      // },
      {
        path: 'addActivity',
        name: 'addActivity',
        meta: {
          title: '活动申请'
        },
        component: () => import('../views/manager/activity/addActivity')
      },
      {
        path: 'activityList',
        meta: {
          title: '活动列表'
        },
        component: () => import('../views/ui/activity/ActivityList')
      },
      {
        path: 'addClub',
        meta: {
          title: '新增社团'
        },
        component: () => import('../views/manager/clubmanage/AddClub')
      },
      {
        path: 'clubInfoUpdate',
        name: 'clubInfoUpdate',
        meta: {
          title: '更新社团'
        },
        component: () => import('../views/manager/clubmanage/ClubInfoUpdate')
      },
      {
        path: 'clubList',
        meta: {
          title: '社团列表'
        },
        component: () => import('../views/ui/club/ClubList')
      },
      {
        path: 'canJoinClubList',
        meta: {
          title: '可加入社团列表'
        },
        component: () => import('../views/ui/club/CanJoinClubList')
      },
      {
        path: 'applyJoinClubList',
        meta: {
          title: '申请加入社团列表'
        },
        component: () => import('../views/ui/club/ApplyJoinClubList')
      },
      {
        path: 'myClub',
        meta: {
          title: '我的社团'
        },
        component: () => import('../views/ui/club/MyClub')
      },
      {
        path: 'clubManage',
        meta: {
          title: '社团管理'
        },
        component: () => import('../views/manager/clubmanage/ClubManage')
      },
      // {
      //   path: 'addActivity/:clubId',
      //   meta: {
      //     title: '增加活动'
      //   },
      //   component: () => import('../views/manager/activity/AddActivity')
      // },
      {
        path: 'memberManage/:clubId',
        meta: {
          title: '人员管理'
        },
        component: () => import('../views/manager/clubmanage/MemberManager')
      },
      {
        path: 'articleList/:clubId',
        meta: {
          title: '文章管理'
        },
        component: () => import('../views/manager/articlemanage/ArticleList'),
      },
      {
        path: 'editArticle',
        component: () => import('../views/manager/articlemanage/EditArticle'),
        name: 'editArticle',
        meta: { title: '修改文章' },
      },
      {
        path: 'addArticle',
        component: () => import('../views/manager/articlemanage/AddArticle'),
        name: 'addArticle',
        meta: { title: '新增文章' },
      },
      {
        path: 'myActivity',
        meta: {
          title: '我的活动'
        },
        component: () => import('../views/manager/activity/MyActivity')
      },
      {
        path: 'canJoinActivityList',
        meta: {
          title: '可以加入的活动'
        },
        component: () => import('../views/manager/activity/CanJoinActivityList')
      },
      {
        path: 'activityManage/:clubId',
        meta: {
          title: '活动管理'
        },
        component: () => import('../views/manager/activity/ActivityManage')
      },
      {
        path: 'updateActivity',
        name: 'updateActivity',
        meta: {
          title: '活动修改'
        },
        component: () => import('../views/manager/activity/UpdateActivity')
      },
      {
        path: 'budgetList/:clubId',
        meta: {
          title: '经费管理'
        },
        component: () => import('../views/manager/budgetmanage/BudgetList')
      },
      {
        path: 'myAccount',
        meta: {
          title: '我的信息'
        },
        component: () => import('../views/manager/account/MyAccount')
      }
    ]
  },
  //社团主页
  {
    path: '/clubHome/:id',
    name: 'clubHome',
    meta: {
      title: '社团主页'
    },
    component: () => import('../views/manager/clubmanage/clubhome/ClubHome.vue')
    ,
    children: [
      {
        path: 'clubNews',
        name: 'clubNews',
        meta: {
          title: '社团资讯'
        },
        component: () => import('../views/manager/clubmanage/clubhome/ClubNews.vue')
      },
      {
        path: 'clubActivity',
        name: 'clubActivity',
        meta: {
          title: '社团活动'
        },
        component: () => import('../views/manager/clubmanage/clubhome/clubActivity.vue')
      },
      {
        path: 'clubInformation',
        name: 'clubInformation',
        meta: {
          title: '社团制度'
        },
        component: () => import('../views/manager/clubmanage/clubhome/clubInformation.vue')
      }
    ],
  },
  //教师管理员后台
  {
    path: '/managerHomeT',
    name: 'ManagerHomeT',
    meta: {
      title: '主页'
    },
    component: () => import('../views/manager/ManagerHomeT.vue'),
    redirect: '/managerHomeT/manageWelcomeT',
    children: [
      {
        path: 'manageWelcomeT',
        name: 'ManageWelcomeT',
        meta: {
          title: '教师端后台管理'
        },
        component: () => import('../views/manager/WelcomeT.vue')
      },
      // {
      //   path: 'activityApprove',
      //   meta: {
      //     title: '活动审批'
      //   },
      //   component: () => import('../views/manager/activitymanage/ActivityApprove')
      // },
      {
        path: 'adminList',
        meta: {
          title: '管理员管理'
        },
        component: () => import('../views/manager/adminmanage/AdminList')
      },
      {
        path: 'clubAudit',
        meta: {
          title: '社团审核'
        },
        component: () => import('../views/manager/clubmanage/ClubAudit.vue')
      },
      {
        path: 'clubList',
        meta: {
          title: '社团审核'
        },
        component: () => import('../views/manager/clubmanage/ClubList.vue')
      },
      {
        path: 'activityAudit',
        meta: {
          title: '活动审核'
        },
        component: () => import('../views/manager/activitymanage/ActivityAudit.vue')
      },
      {
        path: 'studentList',
        meta: {
          title: '管理员管理'
        },
        component: () => import('../views/manager/adminmanage/StudentList')
      },
      // {
      //   path: 'allClub',
      //   meta: {
      //     title: '社团管理'
      //   },
      //   component: () => import('../views/manager/clubmanage/ClubList')
      // }
    ]
  }

]

// 路由导航守卫

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach((to, from, next) => {
//   //to 即将要访问的路径
//   //from 代表从哪里来
//   //next 表示放行
//
//   if (to.path === '/login' || to.path === 'adminLogin') return next()
//
//   //获取token
//   const tokenStr = window.sessionStorage.getItem('token')
//   if(!tokenStr) return  next('login')
//   next()
// })

export default router
